<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%
	request.setAttribute("contextPath", request.getContextPath());
%>
<html>
<head>
<title>用户注册</title>
<!-- wangyong -->
<!-- start jquery -->
<script type="text/javascript" src="${contextPath }/js/jquery-1.7.2.js"></script>
<script type="text/javascript">
	var result = false;
	function check() {

		var userName = $("#userName").val();
		if ("" == userName) {
			return;
		}

		var button = $("input[type=submit]");
		$.ajax({
			url : "${contextPath}/user/check/" + userName,
			type : "post",
			success : function(o) {
				if (o && o.result) {
					console.log("可以注册");
					$("#errTip").hide();
					result = true;
					button.removeAttr("disabled");
				} else {
					console.log("不可以注册");
					$("#errTip").show();
					$("#userName").focus();
					result = false;
					button.attr("disabled", "disabled");
				}
			},
			error : function(o) {
				alert(o);
			}
		}); 
	}
	
	function checkData() {
		if($("#userName").val() == "") {
			$("#errUserName").show();
			return false;
		}
		if($("#password").val() == "") {
			$("#errPassword").show();
			return false;
		}
		if($("#email").val() == "") {
			$("#errEmail").show();
			return false;
		}
		if($("#status").val() == "") {
			$("#errStatus").show();
			return false;
		}
		
		if($("#money").val() == "") {
			$("#errMoney").show();
			return false;
		}
		return true;
	}

</script>

<!-- end jquery -->

</head>
<body bgcolor="#15B69A">
	<h1 style="text-align: center;"><font size="4"></font><font color="#FFFFFF">慧驾网上书城系统用户注册</font></h1>
	<br />
	<br />

	<a href="${contextPath }/admin/home">返回后台</a>
	<form action="${contextPath }/register" method="post" onSubmit="return checkData()">

		<table width="90%" border="1">
			<tr>
				<td>userName<font color="#FF0000">*</font></td>


				<td><input   type="text" name="userName" id="userName" value = "userName"
				  onClick="if(this.value=='userName') this.value='';"
				onBlur="check()"
					/>
					<span id="errUserName" style="color: red; display: none">* 请输入用户名！</span>
					<span id="errTip" style="color: red; display: none">* 用户名已存在，不可注册！</span>
				</td>
				
			</tr>

			<tr>
				<td>password<font color="#FF0000">*</font></td>

				<td><input type="text" name="password" id="password" value = "****"

					onclick="if(this.value=='****') this.value='';"  />
					<span id="errPassword" style="color: red; display: none">* 请输入密码！</span>
				</td>
			</tr>

			<tr>
				<td>email<font color="#FF0000">*</font></td>
				<td><input type="text" name="email" id="email" value ="sample@163.com"
					onclick="if(this.value=='sample@163.com') this.value='';" />
					<span id="errEmail" style="color: red; display: none">* 请输入邮箱！</span>
				</td>
			</tr>
			<tr>
				<td>status</td>
				<td><input type="text" name="status" id="status" value="0" disabled="disabled" />
				<span id="errStatus" style="color: red; display: none">* 请输入状态！</span>
				
				</td>
			</tr>

			<tr>
				<td>money</td>
				<td><input type="text" name="money"  id="money" 
					style="color: red"
					value='100' disabled="disabled"/>
					<span id="errMoney" style="color: red; display: none">* 请输入初始金额！</span>
					</td>
			</tr>
		</table>
		<font color="#00FF00" size="2">
		<table width="981" border="0">
          <tr>
            <td width="102">&nbsp;</td>
            <td width="281"><input name="submit" type="submit" value="Register" /></td>
            <td width="584"><input name="reset" type="reset"
			value="Reset" /></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><font color="#FF0000" size="2">红色为必填项,第一次注册白送100元</font></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><font color="#00FF00">最终解释权在linkage</font></td>
            <td>&nbsp;</td>
          </tr>
        </table>
		</font>
		<p><br />
	  </p>
		<p>&nbsp;    </p>
	</form>
	
</body>
</html>
